<?php
/*
/* 
------------------------------------------------------------------------------------------------------------------------
register sidebars
*/
if ( function_exists('register_sidebar') ) {
	register_sidebar(array('name'=>'Sidebar Left'));
	register_sidebar(array('name'=>'Sidebar Right'));
}

/* 
------------------------------------------------------------------------------------------------------------------------
load theme options controlpanel
*/ 
require_once(TEMPLATEPATH . '/controlpanel.php');


/* 
------------------------------------------------------------------------------------------------------------------------
Frostpress theme options
*/
function fp_options($fp_option) {

global $options;
foreach ($options as $value) {
	if($value['type']!="checkbox" and $value['type']!="multiselect"){
		if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else {
		$$value['id'] = get_settings( $value['id'] ); }
	} else{
		if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = explode(",",$value['std']); } else {
		$$value['id'] = explode(",",get_settings( $value['id'] )); }
	}
}

	$tab = (chr(9));

	if($fp_option == "logo"){

		if(strlen($fp_logo) > 0) { // logo assigned
		
			echo "<a href='". get_settings('home')."'><img src='".$fp_logo."' alt='".get_bloginfo('name')."' border='0' id='logo' /></a>";

		} else { // no logo assigned

			echo "<h1><a href='".get_settings('home')."'>".get_bloginfo('name')."</a></h1>";

			if(strlen(get_bloginfo('description')) > 0) {
				echo "<div class='descOut'><div class='descIn'><h4>".get_bloginfo('description')."</h4></div></div>";
			}

		}

	} elseif($fp_option == "general") {

		if(strlen($fp_color) > 0) { //color scheme
			echo $tab."<link rel='stylesheet' href='".get_bloginfo('template_directory')."/_".strtolower($fp_color).".css' type='text/css' media='all' />\n";
		} else {
			echo $tab."<link rel='stylesheet' href='".get_bloginfo('template_directory')."/_grey.css' type='text/css' media='all' />\n";
		}

		echo $tab."<style type='text/css'>\n";

		if($fp_font == 'Georgia') { // font
			echo $tab.$tab."body, input, select, textarea { font-family: Georgia, serif; }\n";
		} elseif($fp_font == 'Verdana') {
			echo $tab.$tab."body, input, select, textarea { font-family: Verdana, Tahoma, sans-serif; }\n";
		} elseif($fp_font == 'Tahoma') {
			echo $tab.$tab."body, input, select, textarea { font-family: Tahoma, Verdana, sans-serif; }\n";
		} elseif($fp_font == 'Helvetica') {
			echo $tab.$tab."body, input, select, textarea { font-family: Helvetica, Arial, sans-serif; }\n";
		} elseif($fp_font == 'Trebuchet') {
			echo $tab.$tab."body, input, select, textarea { font-family: 'Trebuchet MS', Helvetica, Verdana, sans-serif; }\n";
		}
		
		echo $tab.$tab."body, input, select, textarea { font-size: ".$fp_fontsize."; line-height: 150%; }\n";

		if(strlen($fp_bgimg) > 0) { // background image
			echo $tab.$tab."body { background-image:url('".$fp_bgimg."'); background-position:center top; background-repeat:no-repeat; }\n";
		}
		if($fp_postnav == "No") { // hide post navigation
			echo $tab.$tab.".post-nav { display:none; }\n";
		}
		if($fp_menu == "No") { // hide menu bar
			echo $tab.$tab.".menu { display:none; }\n";
		}
		if($fp_home == "No") { // display home link
			echo $tab.$tab.".home-link { display:none !important; }\n";
		}
		if($fp_post_author == "No") { // display post author
			echo $tab.$tab.".post-author { display:none; }\n";
		}
		if($fp_separator == "No") { // display separator between posts
			echo $tab.$tab.".post { background:none; padding:0px 0px 30px 0px; }\n";
		}
		if($fp_logopos == "Center") { // logo position: center
			echo $tab.$tab."#logo { display:block; margin:0px auto 0px; }\n";
			echo $tab.$tab.".header { text-align:center; }\n";
		}
		if($fp_logopos == "Right") { // logo position: right
			echo $tab.$tab."#logo { float:right; }\n";
			echo $tab.$tab.".header { text-align:right; }\n";
		}
		if($fp_sidebar == "Left") { // sidebar position: left
			echo $tab.$tab.".c1 { display: block; }\n";
			echo $tab.$tab.".c2 { margin: 0px 0px 0px 10px; }\n";
			echo $tab.$tab.".c3 { display: none; }\n";
		}
		if($fp_sidebar == "Left and Right") { // sidebar position: left and right
			echo $tab.$tab.".c1 { display: block; width: 200px; }\n";
			echo $tab.$tab.".c2 { width: 480px; margin: 0px 10px 0px 10px; }\n";
			echo $tab.$tab.".c3 { width: 200px; }\n";
			echo $tab.$tab.".widget_search input { width: 160px; }\n";
		}
		if($fp_sidebar == "Hidden") { // sidebar position: hidden
			echo $tab.$tab.".content .c2 { width:900px; margin:0px; }\n";
			echo $tab.$tab.".content .c3 { display:none; }\n";
		}
		if(strlen($fp_customcss) > 0) { //custom css
			echo $tab.$tab.stripslashes($fp_customcss)."\n";
		}

		echo $tab."</style>";

	} elseif($fp_option == "subscribe") { //subscribe link
		
		?>

		<li class='subscribe'><a href='<?php bloginfo('rss2_url'); ?>' title="Subscribe to the RSS feed" target="_blank"><?php echo $fp_subscribe; ?></a></li>
		
		<?php
		
	} elseif($fp_option == "footer") { //footer text

		if(strlen($fp_footer) > 0) {
			echo stripslashes($fp_footer);
		}

	} elseif($fp_option == "typeFront") { // front page post type

		if ($fp_typeFront == "Full") {
			the_content("Read the full post &raquo;");
		} else {
			the_excerpt();
		}

	} elseif($fp_option == "typeArchive") { // archive page post type

		if ($fp_typeArchive == "Full") {
			the_content("Read the full post &raquo;");
		} else {
			the_excerpt();
		}

	}

}

/*
------------------------------------------------------------------------------------------------------------------------
loads legacy.comments.php as comment file when using a old version of Wordpress
*/
add_filter( 'comments_template', 'legacy_comments' );
function legacy_comments( $file ) {
	if ( !function_exists('wp_list_comments') )
		$file = TEMPLATEPATH . '/legacy.comments.php';
	return $file;
}

/*
------------------------------------------------------------------------------------------------------------------------
custom comment design
*/
function fp_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
	<div class="comment-body" id="div-comment-<?php comment_ID() ?>">
		<div class="comment-meta">
			<?php echo get_avatar($comment,$size='32'); ?>
			<?php printf(__('<h4>%s</h4>'), get_comment_author_link()) ?> &nbsp;/&nbsp;
			<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>" class="comment-date"><?php echo get_comment_date(); ?></a>
			<?php edit_comment_link(__('Edit'),' &nbsp;/&nbsp; ','') ?>
		</div>
		<div class="comment-text">
			<?php if ($comment->comment_approved == '0') : ?>
				<p class="info"><em><?php _e('Your comment is awaiting moderation.') ?></em></p>
			<?php endif; ?>
			<?php comment_text() ?>
		</div>
		<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
	</div><!-- /comment-body -->
<?php
}

/*
------------------------------------------------------------------------------------------------------------------------
custom comment design for printing trackbacks
*/
function fp_trackbacks($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; ?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
		<?php printf(__('%s'), get_comment_author_link()) ?>
<?php
}
?>
